/**
 * Created by Administrator on 2017/4/21.
 */
let mysql = require ("mysql");
let pools = require ("../../../resources/MysqlConfig");
poolCache = {};
module.exports.getPoolConnection = function ( dbName, callback )
{
    if (poolCache[ dbName ])
    {
        poolCache[ dbName ].getConnection (callback);
    }
    else if (pools[ dbName ])
    {
        let pool = mysql.createPool (pools[ dbName ]);
        pool.getConnection (callback);
        poolCache[ dbName ] = pool;
    }
    else
    {
        throw new Error ("database not found");
    }
};